
from pyhanlp import *
# 进行分词
segmented = HanLP.segment('萧炎的妻子是谁？')
print("分词结果:", segmented)
extracted = [term.word for term in segmented if str(term.nature) in {'nr', 'n', 'nz'}]
print("提取结果:", extracted)
segmented = HanLP.segment('中州有哪些势力？')
print("分词结果:", segmented)
extracted = [term.word for term in segmented if str(term.nature) in {'nr', 'n', 'nz'}]
print("提取结果:", extracted)